package com.answeringplayer.exception;

/**
 * 错误码枚举
 */
public enum ErrorCode {

    // 通用错误码
    SUCCESS(200, "成功"),
    BAD_REQUEST(400, "请求参数错误"),
    UNAUTHORIZED(401, "未授权"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "资源不存在"),
    INTERNAL_ERROR(500, "系统内部错误"),

    // 业务错误码
    USER_NOT_FOUND(1001, "用户不存在"),
    USER_EXISTS(1002, "用户已存在"),
    LOGIN_FAILED(1003, "登录失败"),
    TOKEN_EXPIRED(1004, "Token已过期"),
    TOKEN_INVALID(1005, "Token无效"),
    PERMISSION_DENIED(1006, "权限不足"),

    // 考试相关错误码
    EXAM_NOT_FOUND(2001, "考试不存在"),
    EXAM_FINISHED(2002, "考试已结束"),
    EXAM_TIME_LIMIT(2003, "考试时间已到"),

    // 题目相关错误码
    QUESTION_NOT_FOUND(3001, "题目不存在"),
    BANK_NOT_FOUND(3002, "题库不存在"),
    CATEGORY_NOT_FOUND(3003, "分类不存在");

    private final Integer code;
    private final String message;

    ErrorCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}